package com.etop.learnapp.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * 创建各章关键字的数据库
 * Created by John on 2016/1/24.
 */
public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "engineer_dic";

    public static final String TABLE_CHAPTER = "chapter";

    public static final String TABLE_KEYWORD = "keyword";

    public static final String TABLE_TXT = "txt";

    public static final String TABLE_PICTURE = "picture";

    public static final String TABLE_VIDEO = "video";

    public static final String CREATE_CHAPTER_TABLE = "create table "
            + TABLE_CHAPTER
            + " (_id integer primary key autoincrement, cid integer,"
            + " name varchar(10);";

    public static final String CREATE_CHAPTER_KEYWORD = "create table "
            + TABLE_KEYWORD
            + " (_id integer primary key autoincrement, kid integer,"
            + " k_name varchar(10);";

    public static final String CREATE_CHAPTER_TXT = "create table "
            + TABLE_TXT
            + " (_id integer primary key autoincrement, tid integer,"
            + " content text,t_seq integer;";
    public static final String CREATE_CHAPTER_PICTURE = "create table "
            + TABLE_PICTURE
            + " (_id integer primary key autoincrement, pid integer,"
            + " url varchar(50),p_seq integer;";
    public static final String CREATE_CHAPTER_VIDEO = "create table "
            + TABLE_VIDEO
            + " (_id integer primary key autoincrement, vid integer,"
            + " url varchar(50),v_seq integer;";

    public DatabaseHelper(Context context ) {
        super(context, DATABASE_NAME, null, 1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_CHAPTER_TABLE);
        db.execSQL(CREATE_CHAPTER_KEYWORD);
        db.execSQL(CREATE_CHAPTER_TXT);
        db.execSQL(CREATE_CHAPTER_PICTURE);
        db.execSQL(CREATE_CHAPTER_VIDEO);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
